#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <tuple>
#include <vector>
#define ll long long
#define pii pair <int, int>
#define tupl tuple <int, int, int>
using namespace std;
#ifdef ONLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
    int p = 0, flg = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') flg = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        p = p * 10 + c - '0';
        c = getchar();
    }
    return p * flg;
}
void write(ll x) {
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    if (x > 9) {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}
bool _stmer;

#define fi first
#define se second

const int N = 8e5 + 5, M = 2e6 + 5;

namespace G {

array <int, N> fir;
array <int, M> nex, to, len;

int cnt = 1;
void add(int x, int y, int z) {
    cnt++;
    nex[cnt] = fir[x];
    to[cnt] = y;
    len[cnt] = z;
    fir[x] = cnt;
}

} //namespace G

array <array <int, 22>, N> dis;
array <int, N> fa;

void dfs(int x) {
    for (int i = 1; i <= 20; i++) dis[x][i] = 1;
    for (int i = G::fir[x]; i; i = G::nex[i]) {
        if (G::to[i] == fa[x]) continue;
        fa[G::to[i]] = x;
        dfs(G::to[i]);
        for (int j = 1; j <= 20; j++)
            if (j <= G::len[i])
                dis[x][j] += dis[G::to[i]][j];
    }
}

class Uni {

public:

    array <int, N> fa, siz;

    int find(int x) {
        if (fa[x] == x) return x;
        return fa[x] = find(fa[x]);
    }

    void merge(int x, int y) {
        int fx = find(x),
            fy = find(y);
        if (fx == fy) return;
        if (siz[fx] > siz[fy]) swap(fx, fy);
        fa[fx] = fy, siz[fy] += siz[fx];
    }

    void init(int n) {
        for (int i = 1; i <= n; i++)
            siz[fa[i] = i] = 1;
    }

    ll query(int x) {
        x = find(x);
        return 1ll * siz[x] * (siz[x] - 1) / 2;
    }

};

array <vector <pii>, 22> edge;
array <tupl, N> s;

array <Uni, 22> isl;
array <ll, 22> arc, agc;

bool _edmer;
int main() {
    cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
    freopen("tatooine.in", "r", stdin);
    freopen("tatooine.out", "w", stdout);
#endif
    int n = read();
    for (int i = 2; i <= n; i++) {
        int x = read(), y = read(), z = read();
        G::add(x, y, z), G::add(y, x, z);
        edge[z].push_back(make_pair(x, y));
        s[i - 1] = make_tuple(x, y, z);
    }
    dfs(1);
    isl[21].init(n);
    for (int i = 20; i >= 1; i--) {
        isl[i] = isl[i + 1];
        for (auto k : edge[i])
            isl[i].merge(k.fi, k.se);
        for (int j = 1; j <= n; j++)
            if (isl[i].find(j) == j)
                arc[i] += isl[i].query(j);
    }
    for (int i = 1; i < n; i++) {
        agc = arc;
        int x = 0, y = 0, k = 0; tie(x, y, k) = s[i];
        if (fa[y] == x) swap(x, y);
        for (int j = k; j >= 1; j--) {
            agc[j] -= isl[j].query(x);
            int tp1 = dis[x][j], tp2 = isl[j].siz[isl[j].find(x)] - tp1;
            agc[j] += 1ll * tp1 * (tp1 - 1) / 2;
            agc[j] += 1ll * tp2 * (tp2 - 1) / 2;
        }
        ll ans = 0;
        for (int j = 1; j <= 20; j++)
            ans += (agc[j] - agc[j + 1]) * j;
        write(ans), puts("");
    }
    return 0;
}
